﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Test.DomainModel.Entities;
using EnterApp.Core.DomainModel;
using EnterApp.Core.IoC;
using Test.DomainModel.Services;

namespace Test.DomainModel.Roles
{
    public class Borrower : Role<LibraryAccount, UniqueId>, IBorrower
    {
        private ILibraryService library = DependencyResolver.Resolve<ILibraryService>();

        public Borrower(LibraryAccount account)
            : base(account)
        {
            if (account.IsLocked)
            {
                throw new NotSupportedException("Locked account is not allowed to act as borrower.");
            }
        }

        public void BorrowBook(Book book)
        {
            //通知图书馆把书借给我
            library.LendBook(book, this);
        }
        public void ReturnBook(Book book)
        {
            //通知图书馆接收我要归还的书
            library.ReceiveReturnedBook(book, this);
        }
    }
}
